import { defHttp } from '/@/utils/http/axios';
import { IdModel } from '/@/api/model/baseModel';
import {
  DictionaryListModel,
  DictionaryListQueryParam,
  DictionarySaveModel,
} from '/@/views/system/dictionary/model';

enum Api {
  GetList = '/dictionary/find',
  Save = '/dictionary/save',
  Update = '/dictionary/update',
  Del = '/dictionary/delete',
}

/**
 * @description: 角色列表
 */
export const getList = (params: DictionaryListQueryParam) => {
  return defHttp.get<DictionaryListModel>({ url: Api.GetList, params });
};

/**
 * @description: 保存角色
 */
export const save = (params: DictionarySaveModel) => {
  return defHttp.post<DictionarySaveModel>({
    url: Api.Save,
    params,
  });
};

/**
 * @description: 更新角色信息
 */
export const update = (params: DictionarySaveModel) => {
  return defHttp.post<DictionarySaveModel>({
    url: Api.Update,
    params,
  });
};

/**
 * @description: 删除角色
 */
export const del = (params: IdModel) => {
  return defHttp.delete<IdModel>({
    url: `${Api.Del}?id=${params.id}`,
  });
};
